home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / admin / xinetd.2 / xinetd / xinetd.2.1.7-linux.4 / libs / src / str / str.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-25  |  3.5 KB  |  140 lines

  1. /*
  2.  * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  3.  * All rights reserved.  The file named COPYRIGHT specifies the terms 
  4.  * and conditions for redistribution.
  5.  */
  6.  
  7.  
  8. #ifndef __STR_H
  9. #define __STR_H
  10.  
  11. /*
  12.  * $Id: str.h,v 3.1 1993/06/13 02:47:14 panos Exp $
  13.  */
  14.  
  15. #include <varargs.h>
  16.  
  17.  
  18. #ifdef __ARGS
  19. #undef __ARGS
  20. #endif
  21.  
  22. #ifdef PROTOTYPES
  23. #   define __ARGS( s )               s
  24. #else
  25. #   define __ARGS( s )               ()
  26. #endif
  27.  
  28.  
  29. /*
  30.  * strprint(3) functions
  31.  */
  32. char *str_sprint __ARGS( ( char *buf, char *fmt, ... ) ) ;
  33. int str_nprint __ARGS( ( char *buf, char *fmt, ... ) ) ;
  34. void str_print __ARGS( ( int *count, char *buf, char *fmt, ... ) ) ;
  35.  
  36. char *str_sprintv __ARGS( ( char *buf, char *fmt, va_list ) ) ;
  37. int str_nprintv __ARGS( ( char *buf, char *fmt, va_list ) ) ;
  38. void str_printv __ARGS( ( int *count, char *buf, char *fmt, va_list ) ) ;
  39.  
  40. char *strx_sprint __ARGS( ( char *buf, int len, char *fmt, ... ) ) ;
  41. int strx_nprint __ARGS( ( char *buf, int len, char *fmt, ... ) ) ;
  42. void strx_print __ARGS( ( int *count, char *buf, int len, char *fmt, ... ) ) ;
  43.  
  44. char *strx_sprintv __ARGS( ( char *buf, int len, char *fmt, va_list ) ) ;
  45. int strx_nprintv __ARGS( ( char *buf, int len, char *fmt, va_list ) ) ;
  46. void strx_printv __ARGS(( int *cnt, char *buf, int len, char *fmt, va_list )) ;
  47.  
  48.  
  49. /*
  50.  * strparse(3) functions
  51.  */
  52.  
  53. /*
  54.  * Return values
  55.  */
  56. #define STR_OK                        0
  57. #define STR_ERR                    (-1)
  58.  
  59.  
  60. /* 
  61.  * Flags for the string parsing functions
  62.  */
  63. #define STR_NOFLAGS                0x0
  64. #define STR_RETURN_ERROR        0x1
  65. #define STR_NULL_START            0x2
  66. #define STR_NULL_END                0x4
  67. #define STR_MALLOC                0x8
  68.  
  69. extern int str_errno ;
  70.  
  71. /*
  72.  * Error values
  73.  */
  74. #define STR_ENULLSEPAR            1
  75. #define STR_ENULLSTRING            2
  76. #define STR_ENOMEM                3
  77.  
  78. typedef void *str_h ;
  79.  
  80. str_h str_parse __ARGS( ( char *str, char *separ, int flags, int *errnop ) ) ;
  81. void str_endparse __ARGS( ( str_h handle ) ) ;
  82. char *str_component __ARGS( ( str_h handle ) ) ;
  83. int str_setstr __ARGS( ( str_h handle, char *newstr ) ) ;
  84. int str_separator __ARGS( ( str_h handle, char *separ ) ) ;
  85. char *str_nextpos __ARGS( ( str_h handle ) ) ;
  86.  
  87. /*
  88.  * For backwards compatibility
  89.  */
  90. #define str_process( s, sep, flags )    str_parse( s, sep, flags, (int *)0 )
  91. #define str_endprocess( handle )            str_endparse( handle )
  92.  
  93.  
  94. /*
  95.  * strutil(3) functions
  96.  */
  97. char *str_find __ARGS( ( char *s1, char *s2 ) ) ;
  98. char *str_casefind __ARGS( ( char *s1, char *s2 ) ) ;
  99. void str_fill __ARGS( ( char *s, char c ) ) ;
  100. char *str_lower __ARGS( ( char *s ) ) ;
  101. char *str_upper __ARGS( ( char *s ) ) ;
  102.  
  103.  
  104. /*
  105.  * strsearch(3) functions
  106.  */
  107.  
  108. /*
  109.  * Methods
  110.  */
  111. #define STRS_BF                                0            /* brute force                */
  112. #define STRS_RK                                1            /* Rabin-Karp                */
  113. #define STRS_KMP                                2            /* Knuth-Morris-Pratt    */
  114. #define STRS_SBM                                3            /* Simple Boyer-Moore    */
  115. #define STRS_BMH                                4            /* Boyer-Moore-Horspool */
  116. #define STRS_SO                                5            /* Shift-Or                    */
  117.  
  118. #define __STRS_METHOD_BITS                    5
  119. #define STRS_METHODS_MAX                    ( 1 << __STRS_METHOD_BITS )
  120.  
  121. /*
  122.  * Flags
  123.  */
  124. #define __STRS_MAKEFLAG( v )                ( (v) << __STRS_METHOD_BITS )
  125. #define STRS_IGNCASE                            __STRS_MAKEFLAG( 0x1 )
  126. #define STRS_NOMALLOC                        __STRS_MAKEFLAG( 0x2 )
  127. #define STRS_NOSWITCH                        __STRS_MAKEFLAG( 0x4 )
  128. #define STRS_PATLEN                            __STRS_MAKEFLAG( 0x8 )
  129.  
  130.  
  131. typedef void *strs_h ;
  132.  
  133. char *strs_search __ARGS( ( int flags, char *str, int len, char *pat, ... ) ) ;
  134. strs_h strs_setup __ARGS( ( int flags, char *pattern, ... ) ) ;
  135. char *strs_match    __ARGS( ( strs_h handle, char *str, int len ) ) ;
  136. void strs_done        __ARGS( ( strs_h handle ) ) ;
  137.  
  138. #endif     /* __STR_H */
  139.  
  140.